Setup
Necessary Libraries
library(MicrobeR)
library(dada2)
library(vegan)
library(ape)
library(philr)
library(lmerTest)
library(tidyverse)
library(readxl)
library(phyloseq)
library(ggtree)
library(qiime2R)
library(ALDEx2)
library(gghighlight)
library(ggpubr)
library(patchwork)
sessionInfo()
## R version 3.6.3 (2020-02-29)
## Platform: x86_64-apple-darwin15.6.0 (64-bit)
## Running under: macOS Mojave 10.14.6
##
## Matrix products: default
## BLAS: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRblas.0.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib
##
## locale:
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] patchwork_1.1.1 ggpubr_0.4.0 gghighlight_0.3.0 ALDEx2_1.18.0
## [5] qiime2R_0.99.34 ggtree_2.0.4 phyloseq_1.30.0 readxl_1.3.1
## [9] forcats_0.5.0 stringr_1.4.0 dplyr_0.8.5 purrr_0.3.4
## [13] readr_1.3.1 tidyr_1.0.2 tibble_3.0.1 ggplot2_3.3.0
## [17] tidyverse_1.3.0 lmerTest_3.1-2 lme4_1.1-23 Matrix_1.2-18
## [21] philr_1.12.0 ape_5.3 vegan_2.5-6 lattice_0.20-38
## [25] permute_0.9-5 dada2_1.14.1 Rcpp_1.0.4 MicrobeR_0.3.2
##
## loaded via a namespace (and not attached):
## [1] backports_1.1.6 Hmisc_4.4-0
## [3] fastmatch_1.1-0 plyr_1.8.6
## [5] igraph_1.2.5 lazyeval_0.2.2
## [7] splines_3.6.3 BiocParallel_1.20.1
## [9] GenomeInfoDb_1.22.1 rtk_0.2.5.8
## [11] digest_0.6.25 foreach_1.5.0
## [13] htmltools_0.5.0 fansi_0.4.1
## [15] checkmate_2.0.0 magrittr_1.5
## [17] memoise_1.1.0 cluster_2.1.0
## [19] DECIPHER_2.14.0 openxlsx_4.1.5
## [21] Biostrings_2.54.0 modelr_0.1.6
## [23] RcppParallel_5.0.0 matrixStats_0.56.0
## [25] jpeg_0.1-8.1 colorspace_1.4-1
## [27] blob_1.2.1 rvest_0.3.5
## [29] haven_2.2.0 xfun_0.13
## [31] crayon_1.3.4 RCurl_1.98-1.2
## [33] jsonlite_1.6.1 survival_3.1-8
## [35] phangorn_2.5.5 iterators_1.0.12
## [37] glue_1.4.0 gtable_0.3.0
## [39] zlibbioc_1.32.0 XVector_0.26.0
## [41] DelayedArray_0.12.3 car_3.0-8
## [43] Rhdf5lib_1.8.0 BiocGenerics_0.32.0
## [45] abind_1.4-5 scales_1.1.0
## [47] DBI_1.1.0 rstatix_0.6.0
## [49] htmlTable_1.13.3 viridisLite_0.3.0
## [51] tidytree_0.3.3 foreign_0.8-75
## [53] bit_1.1-15.2 Formula_1.2-3
## [55] stats4_3.6.3 DT_0.13
## [57] truncnorm_1.0-8 htmlwidgets_1.5.1
## [59] httr_1.4.1 RColorBrewer_1.1-2
## [61] acepack_1.4.1 ellipsis_0.3.0
## [63] pkgconfig_2.0.3 NADA_1.6-1.1
## [65] nnet_7.3-12 dbplyr_1.4.3
## [67] tidyselect_1.0.0 rlang_0.4.5
## [69] reshape2_1.4.4 munsell_0.5.0
## [71] cellranger_1.1.0 tools_3.6.3
## [73] cli_2.0.2 generics_0.0.2
## [75] RSQLite_2.2.0 ade4_1.7-15
## [77] broom_0.5.6 evaluate_0.14
## [79] biomformat_1.14.0 yaml_2.2.1
## [81] knitr_1.28 bit64_0.9-7
## [83] fs_1.4.1 zip_2.0.4
## [85] nlme_3.1-144 xml2_1.3.2
## [87] rstudioapi_0.11 compiler_3.6.3
## [89] curl_4.3 plotly_4.9.2.1
## [91] png_0.1-7 ggsignif_0.6.0
## [93] zCompositions_1.3.4 reprex_0.3.0
## [95] treeio_1.10.0 statmod_1.4.34
## [97] stringi_1.4.6 nloptr_1.2.2.1
## [99] multtest_2.42.0 vctrs_0.2.4
## [101] pillar_1.4.3 lifecycle_0.2.0
## [103] BiocManager_1.30.10 data.table_1.12.8
## [105] bitops_1.0-6 GenomicRanges_1.38.0
## [107] R6_2.4.1 latticeExtra_0.6-29
## [109] hwriter_1.3.2 ShortRead_1.44.3
## [111] rio_0.5.16 gridExtra_2.3
## [113] IRanges_2.20.2 codetools_0.2-16
## [115] boot_1.3-24 MASS_7.3-51.5
## [117] assertthat_0.2.1 picante_1.8.1
## [119] rhdf5_2.30.1 SummarizedExperiment_1.16.1
## [121] withr_2.2.0 GenomicAlignments_1.22.1
## [123] Rsamtools_2.2.3 S4Vectors_0.24.4
## [125] GenomeInfoDbData_1.2.2 mgcv_1.8-31
## [127] parallel_3.6.3 hms_0.5.3
## [129] rpart_4.1-15 quadprog_1.5-8
## [131] grid_3.6.3 minqa_1.2.4
## [133] rmarkdown_2.1 rvcheck_0.1.8
## [135] carData_3.0-4 base64enc_0.1-3
## [137] numDeriv_2016.8-1.1 Biobase_2.46.0
## [139] lubridate_1.7.8
Theme
Whitecolor="#E69F00"
Chinesecolor="#0072B2"
# theme for pcoas
theme_pcoa<- function () {
theme_classic(base_size=10, base_family="Helvetica") +
theme(axis.text = element_text(size=8, color = "black"),
axis.title = element_text(size=10, color="black"),
legend.text = element_text(size=8, color = "black"),
legend.title = element_text(size=10, color = "black"),
plot.title = element_text(size=10, color="black")) +
theme(panel.border = element_rect(color="black", size=1, fill=NA))
}
# theme for boxplots
theme_boxplot<- function () {
theme_classic(base_size=10, base_family="Helvetica") +
theme(axis.text.x = element_text(size=10, color = "black"),
axis.text.y = element_text(size=8, color="black"),
axis.title.x= element_blank(),
axis.title.y = element_text(size=10, color="black"),
legend.position = "none")
}
Data Import
metadata<-read_excel("/Volumes/turnbaughlab/qb3share/qiyanang/IDEO_manuscript_Rd2/data/metadata_IDEO_cohort.xlsx") %>% column_to_rownames("SampleID")
SVtab<-read_qza("/Volumes/turnbaughlab/qb3share/qiyanang/16S_IDEO_FonlyNewPipeline/Output/ASV_table.qza")$data %>% as.data.frame()
SVseq<-read_qza("/Volumes/turnbaughlab/qb3share/qiyanang/16S_IDEO_FonlyNewPipeline/Output/ASV_sequences.qza")$data %>% as.data.frame() %>% rename("SV"=x)
taxonomy<-read.delim("/Volumes/turnbaughlab/qb3share/qiyanang/16S_IDEO_FonlyNewPipeline/Output/ASV_d2taxonomy.txt", header=T)
lookup<-(SVseq %>% rownames_to_column("ASV")) %>%
left_join(taxonomy, by="ASV") %>%
column_to_rownames("ASV")
## Warning: Column `ASV` joining character vector and factor, coercing into
## character vector
# Tree
tree<-read_qza("/Volumes/turnbaughlab/qb3share/qiyanang/16S_IDEO_FonlyNewPipeline/Output/ASV_denovotree.qza")$data
Filter SV table
# Correct typos in SVtab colnames
names(SVtab) <- gsub(x = names(SVtab), pattern = "0B0", replacement = "OB0")
# Subset SVtab to contain only White and Chinese samples
SVtab<-SVtab[,rownames(metadata)]
histogram(colSums(SVtab))

print("Read count for samples used in downstream analysis range 72091-319590")
## [1] "Read count for samples used in downstream analysis range 72091-319590"
Quality Filter
SVtab<-Confidence.Filter(SVtab, MINSAMPS = 2, MINREADS=10, VERBOSE=TRUE)
lookup<-lookup[rownames(SVtab),]
tree<-drop.tip(tree, tree$tip.label[!tree$tip.label %in% rownames(lookup)])
Normalized Tables
PHILR<-philr(
t(SVtab+1),
tree,
part.weights='enorm.x.gm.counts',
ilr.weights='blw.sqrt'
)
## Building Sequential Binary Partition from Tree...
## Building Contrast Matrix...
## Transforming the Data...
## Calculating ILR Weights...
## Warning in calculate.blw(tree, method = "sum.children"): Note: a total of 105
## tip edges with zero length have been replaced with a small pseudocount of the
## minimum non-zero edge length ( 5e-09 ).
Alpha Diversity
alphadiv <- data.frame(
Shannon = vegan::diversity(Subsample.Table(SVtab), index = "shannon", MARGIN = 2),
FaithsPD = picante::pd(t(Subsample.Table(SVtab)), tree, include.root = F)$PD,
Richness = specnumber(Subsample.Table(SVtab), MARGIN = 2)) %>% #Calc richness on subsampled table
rownames_to_column("SampleID") %>%
left_join(metadata %>% rownames_to_column("SampleID")) %>%
select (SampleID, Ethnicity, IDEO_BMI_Class, Shannon, FaithsPD, Richness, BMI,`%BF`) %>%
pivot_longer(cols=Shannon:Richness, names_to="alpha_metric")
## Subsampling feature table to 69340 , currently has 1308 taxa.
## ...sampled to 69340 reads with 1305 taxa
## Subsampling feature table to 69340 , currently has 1308 taxa.
## ...sampled to 69340 reads with 1305 taxa
## Subsampling feature table to 69340 , currently has 1308 taxa.
## ...sampled to 69340 reads with 1305 taxa
## Joining, by = "SampleID"
# plot alpha div metrics
alphadiv %>%
ggplot(aes(x=IDEO_BMI_Class, y=value, fill=Ethnicity)) +
geom_boxplot(outlier.shape=NA) +
facet_wrap(~alpha_metric, scales="free", nrow=1) +
theme_boxplot() +
theme(legend.position = "right") +
scale_fill_manual(values = c(EA=Chinesecolor, W=Whitecolor)) +
ylab("Alpha diversity") +
stat_compare_means(method = "wilcox.test", paired = FALSE, label = "p.format")

#ggsave("/Volumes/turnbaughlab/qb3share/qiyanang/IDEO_manuscript_Rd2/figures/figures_16S_human_leanobese/alphadiv_leanobese.pdf", height=2.5, width=6, useDingbats=F)
# stats
alphadiv %>%
group_by(alpha_metric, IDEO_BMI_Class) %>%
do(
broom::glance(wilcox.test(value~Ethnicity, data=., paired=F))
) %>%
ungroup() -> results.alpha
## Warning in wilcox.test.default(x = c(268, 300, 281, 160, 202, 262, 164, : cannot
## compute exact p-value with ties
## Warning in wilcox.test.default(x = c(271, 147, 196, 181, 230, 169, 185, : cannot
## compute exact p-value with ties
Nice.Table(results.alpha)
Correlation bw alpha div and metabolic parameters
Correlation stats
alphadiv %>%
group_by(alpha_metric, Ethnicity) %>%
do(
broom::glance(cor.test(~value+BMI, data=., method="spearman", conf.level = 0.95))
) %>%
ungroup() -> results.alpha.cor.BMI
## Warning in cor.test.default(x = c(17.433724333, 10.718564998, 13.875079969, :
## Cannot compute exact p-value with ties
## Warning in cor.test.default(x = c(15.473810632, 12.618487713, 16.065054884, :
## Cannot compute exact p-value with ties
## Warning in cor.test.default(x = c(271, 147, 196, 181, 268, 300, 281, 160, :
## Cannot compute exact p-value with ties
## Warning in cor.test.default(x = c(237, 205, 237, 227, 216, 291, 151, 225, :
## Cannot compute exact p-value with ties
## Warning in cor.test.default(x = c(3.75391221497536, 3.28392747785931,
## 3.65868347495839, : Cannot compute exact p-value with ties
## Warning in cor.test.default(x = c(3.47753869036769, 4.01093947025265,
## 3.93037963333439, : Cannot compute exact p-value with ties
Nice.Table(results.alpha.cor.BMI)
alphadiv %>%
group_by(alpha_metric, Ethnicity) %>%
do(
broom::glance(cor.test(~value+as.numeric(`%BF`), data=., method="spearman", conf.level = 0.95))
) %>%
ungroup() -> results.alpha.cor.BF
## Warning in cor.test.default(x = c(17.433724333, 10.718564998, 13.875079969, :
## Cannot compute exact p-value with ties
## Warning in eval(predvars, data, env): NAs introduced by coercion
## Warning in cor.test.default(x = c(15.473810632, 12.618487713, 15.3622618, :
## Cannot compute exact p-value with ties
## Warning in cor.test.default(x = c(271, 147, 196, 181, 268, 300, 281, 160, :
## Cannot compute exact p-value with ties
## Warning in eval(predvars, data, env): NAs introduced by coercion
## Warning in cor.test.default(x = c(237, 205, 227, 216, 291, 151, 225, 203, :
## Cannot compute exact p-value with ties
## Warning in cor.test.default(x = c(3.75391221497536, 3.28392747785931,
## 3.65868347495839, : Cannot compute exact p-value with ties
## Warning in eval(predvars, data, env): NAs introduced by coercion
## Warning in cor.test.default(x = c(3.47753869036769, 4.01093947025265,
## 3.77358789674242, : Cannot compute exact p-value with ties
Nice.Table(results.alpha.cor.BF)
Plot Richness corr to BMI/BF (main fig)
# plot Richness to BMI
richness_bmi <- alphadiv %>%
filter(alpha_metric=="Richness") %>%
ggplot(aes(x=as.numeric(BMI), y=value, fill=Ethnicity)) +
stat_smooth(method="lm", color="black", size=1) +
geom_point(size=2, shape=21) +
facet_wrap(~Ethnicity) +
scale_fill_manual(values = c(EA=Chinesecolor, W=Whitecolor)) +
theme_pcoa() +
theme(legend.position = "none") +
xlab("BMI") +
ylab("Richness")
# plot Richness to %BF
richness_vat <- alphadiv %>%
filter(alpha_metric=="Richness") %>%
ggplot(aes(x=as.numeric(`%BF`), y=value, fill=Ethnicity)) +
stat_smooth(method="lm", color="black", size=1) +
geom_point(size=2, shape=21) +
facet_wrap(~Ethnicity) +
theme(legend.position = "none") +
scale_fill_manual(values = c(EA=Chinesecolor, W=Whitecolor)) +
theme_pcoa() +
theme(legend.position = "none") +
xlab("Body fat, %") +
ylab("Richness")
# combine both plots
richness_bmi / richness_vat
## `geom_smooth()` using formula 'y ~ x'
## Warning in FUN(X[[i]], ...): NAs introduced by coercion
## Warning in FUN(X[[i]], ...): NAs introduced by coercion
## Warning in FUN(X[[i]], ...): NAs introduced by coercion
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 1 rows containing non-finite values (stat_smooth).
## Warning: Removed 1 rows containing missing values (geom_point).

#ggsave("/Volumes/turnbaughlab/qb3share/qiyanang/IDEO_manuscript_Rd2/figures/figures_16S_human_leanobese/alphadiv_metabolic_corr_main.pdf", height=4, width=3.5, useDingbats=F)
Plot FaithsPD and Shannon (suppl fig)
# plot Shannon to BMI
shannon_bmi <- alphadiv %>%
filter(alpha_metric=="Shannon") %>%
ggplot(aes(x=as.numeric(BMI), y=value, fill=Ethnicity)) +
stat_smooth(method="lm", color="black", size=1) +
geom_point(size=2, shape=21) +
facet_wrap(~Ethnicity) +
scale_fill_manual(values = c(EA=Chinesecolor, W=Whitecolor)) +
theme_pcoa() +
theme(legend.position = "none") +
xlab("BMI") +
ylab("Shannon diversity")
# plot Shannon to %BF
shannon_vat <- alphadiv %>%
filter(alpha_metric=="Shannon") %>%
ggplot(aes(x=as.numeric(`%BF`), y=value, fill=Ethnicity)) +
stat_smooth(method="lm", color="black", size=1) +
geom_point(size=2, shape=21) +
facet_wrap(~Ethnicity) +
scale_fill_manual(values = c(EA=Chinesecolor, W=Whitecolor)) +
theme_pcoa() +
theme(legend.position = "none") +
xlab("Body fat, %") +
ylab("Shannon diversity")
# plot FaithsPD to BMI
faiths_bmi <- alphadiv %>%
filter(alpha_metric=="FaithsPD") %>%
ggplot(aes(x=as.numeric(BMI), y=value, fill=Ethnicity)) +
stat_smooth(method="lm", color="black", size=1) +
geom_point(size=2, shape=21) +
facet_wrap(~Ethnicity) +
scale_fill_manual(values = c(EA=Chinesecolor, W=Whitecolor)) +
theme_pcoa() +
theme(legend.position = "none") +
xlab("BMI") +
ylab("Faith's diversity")
# plot FatihsPD to %BF
faiths_vat <- alphadiv %>%
filter(alpha_metric=="FaithsPD") %>%
ggplot(aes(x=as.numeric(`%BF`), y=value, fill=Ethnicity)) +
stat_smooth(method="lm", color="black", size=1) +
geom_point(size=2, shape=21) +
facet_wrap(~Ethnicity) +
scale_fill_manual(values = c(EA=Chinesecolor, W=Whitecolor)) +
theme_pcoa() +
theme(legend.position = "none") +
xlab("Body fat, %") +
ylab("Faith's diversity")
# Combine panels
(faiths_bmi | faiths_vat) / (shannon_bmi | shannon_vat) + plot_annotation(tag_levels = "A")
## `geom_smooth()` using formula 'y ~ x'
## Warning in FUN(X[[i]], ...): NAs introduced by coercion
## Warning in FUN(X[[i]], ...): NAs introduced by coercion
## Warning in FUN(X[[i]], ...): NAs introduced by coercion
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 1 rows containing non-finite values (stat_smooth).
## Warning: Removed 1 rows containing missing values (geom_point).
## `geom_smooth()` using formula 'y ~ x'
## Warning in FUN(X[[i]], ...): NAs introduced by coercion
## Warning in FUN(X[[i]], ...): NAs introduced by coercion
## Warning in FUN(X[[i]], ...): NAs introduced by coercion
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 1 rows containing non-finite values (stat_smooth).
## Warning: Removed 1 rows containing missing values (geom_point).

#ggsave("/Volumes/turnbaughlab/qb3share/qiyanang/IDEO_manuscript_Rd2/figures/figures_16S_human_leanobese/alphadiv_metabolic_corr_suppl.pdf", height=4, width=6, useDingbats=F)
Phylum Abundances
Summarize.Taxa(SVtab, lookup)$Phylum %>%
Make.CLR() %>%
as.data.frame() %>%
rownames_to_column("Feature") %>%
gather(-Feature, key="SampleID", value="Abundance") %>%
left_join(metadata %>% rownames_to_column("SampleID"), by="SampleID") %>%
select(Feature, SampleID, Abundance, SubjectID, Ethnicity, IDEO_BMI_Class) -> data
## WARNING: CLR being applied with relatively few features.
# top 5 phyla
# data %>%
# group_by(Feature) %>%
# summarize(AvgAbundance=mean(Abundance)) %>%
# top_n(n=6, wt=AvgAbundance) -> top_phyla
# significant phyla
data %>%
group_by(Feature) %>%
do(
broom::glance(wilcox.test(Abundance~Ethnicity, data=., paired=FALSE))
) %>%
ungroup() -> results.phylum
results.phylum %>% filter(p.value<0.05) -> sig_phyla
Nice.Table(results.phylum)
# plot phyla
data %>%
filter(Feature %in% sig_phyla$Feature) %>%
separate(Feature, sep=";", into=c("Kingdom","Phylum")) %>%
mutate(Phylum=factor(Phylum, levels=c("Firmicutes","Bacteroidota","Actinobacteriota","Proteobacteria","Verrucomicrobiota","Fusobacteriota"))) %>%
ggplot(aes(x=IDEO_BMI_Class, y=Abundance, fill=Ethnicity)) +
geom_boxplot(outlier.shape=NA) +
facet_wrap(~Phylum, nrow=1, scales="free") +
theme_boxplot() +
theme(legend.position = "right") +
scale_fill_manual(values = c(EA=Chinesecolor, W=Whitecolor)) +
ylab("Abundance (CLR)") +
stat_compare_means(method = "wilcox.test",paired = FALSE,label = "p.format")

#ggsave("/Volumes/turnbaughlab/qb3share/qiyanang/IDEO_manuscript_Rd2/figures/figures_16S_human_leanobese/phyla_leanobese.pdf", height=2.5, width=10, useDingbats=F)
Beta Diversity (PhILR): Lean
# filter lean subjects
f.meta<-metadata %>% rownames_to_column("SampleID") %>% filter(IDEO_BMI_Class=="Lean")
f.PHILR<-PHILR[f.meta$SampleID,]
#Adonis
adonis<-vegan::adonis(dist(f.PHILR, method="euclidean") ~ Ethnicity, data=f.meta, permutations=10000)
adonis$aov.tab
## Permutation: free
## Number of permutations: 10000
##
## Terms added sequentially (first to last)
##
## Df SumsOfSqs MeanSqs F.Model R2 Pr(>F)
## Ethnicity 1 3242.6 3242.6 2.9102 0.12171 3e-04 ***
## Residuals 21 23398.5 1114.2 0.87829
## Total 22 26641.1 1.00000
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#Calculate PCo axis values
euclid<-ape::pcoa(dist(f.PHILR, method="euclidean"))
var.PCo1 <- format(100*(euclid$values$Eigenvalues/sum(euclid$values$Eigenvalues))[1], digits=2, nsmall=1)
var.PCo2 <- format(100*(euclid$values$Eigenvalues/sum(euclid$values$Eigenvalues))[2], digits=2, nsmall=1)
#Plot pcoa
euclid$vectors %>%
as.data.frame() %>%
rownames_to_column("SampleID") %>%
left_join(metadata %>% rownames_to_column("SampleID")) %>%
ggplot(aes(x=Axis.1, y=Axis.2, fill=Ethnicity)) +
geom_point(size=2, shape=21) +
theme_pcoa() +
ylab(paste0("PCo2 [",var.PCo2,"%]")) +
xlab(paste0("PCo1 [",var.PCo1,"%]")) +
scale_fill_manual(values = c(EA=Chinesecolor, W=Whitecolor)) +
ggtitle(paste0("PhILR (Lean): p=",adonis$aov.tab$`Pr(>F)`,", r2=",round(adonis$aov.tab$R2[1],digits=3))) +
theme(legend.position = "none")
## Joining, by = "SampleID"

#ggsave("/Volumes/turnbaughlab/qb3share/qiyanang/IDEO_manuscript_Rd2/figures/figures_16S_human_leanobese/pcoa_lean.pdf", height=2.5, width=2.5, useDingbats=F)
Beta Diversity (PhILR Euclidean): Obese
# filter obese subjects
f.meta<-metadata %>% rownames_to_column("SampleID") %>% filter(IDEO_BMI_Class=="Obese")
f.PHILR<-PHILR[f.meta$SampleID,]
#Adonis
adonis<-vegan::adonis(dist(f.PHILR, method="euclidean") ~ Ethnicity, data=f.meta, permutations=10000)
adonis$aov.tab
## Permutation: free
## Number of permutations: 10000
##
## Terms added sequentially (first to last)
##
## Df SumsOfSqs MeanSqs F.Model R2 Pr(>F)
## Ethnicity 1 1784.3 1784.3 1.3279 0.05947 0.1423
## Residuals 21 28217.0 1343.7 0.94053
## Total 22 30001.3 1.00000
#Calculate PCo axis values
euclid<-ape::pcoa(dist(f.PHILR, method="euclidean"))
var.PCo1 <- format(100*(euclid$values$Eigenvalues/sum(euclid$values$Eigenvalues))[1], digits=2, nsmall=1)
var.PCo2 <- format(100*(euclid$values$Eigenvalues/sum(euclid$values$Eigenvalues))[2], digits=2, nsmall=1)
#Plot pcoa
euclid$vectors %>%
as.data.frame() %>%
rownames_to_column("SampleID") %>%
left_join(metadata %>% rownames_to_column("SampleID")) %>%
ggplot(aes(x=Axis.1, y=Axis.2, fill=Ethnicity)) +
geom_point(size=2, shape=21) +
theme_pcoa() +
ylab(paste0("PCo2 [",var.PCo2,"%]")) +
xlab(paste0("PCo1 [",var.PCo1,"%]")) +
scale_fill_manual(values = c(EA=Chinesecolor, W=Whitecolor)) +
ggtitle(paste0("PhILR (Obese): p=",adonis$aov.tab$`Pr(>F)`,", r2=",round(adonis$aov.tab$R2[1],digits=3))) +
theme(legend.position = "none")
## Joining, by = "SampleID"

#ggsave("/Volumes/turnbaughlab/qb3share/qiyanang/IDEO_manuscript_Rd2/figures/figures_16S_human_leanobese/pcoa_obese.pdf", height=2.5, width=2.5, useDingbats=F)
Differential Abundance on genera: Aldex2 (Lean subjects)
# filter lean subjects
f.meta<-metadata %>% rownames_to_column("SampleID") %>% filter(IDEO_BMI_Class=="Lean")
f.SVtab<-SVtab[,f.meta$SampleID]
# summarize table to genus level
genera<-Summarize.Taxa(f.SVtab, lookup)$Genus
f.genera<-Fraction.Filter(genera,0.0005)
## [1] "Filtering table at a min fraction of 5e-04 of feature table..."
## [1] "...There are 5289790 reads and 243 features"
## [1] "...After filtering there are 5220143 reads and 99 OTUs"
# aldex
results <- aldex(f.genera, f.meta$Ethnicity, mc.samples = 128, denom = "all", test = "t", effect = TRUE, include.sample.summary = TRUE)
## aldex.clr: generating Monte-Carlo instances and clr values
## operating in serial mode
## computing center with all features
## aldex.ttest: doing t-test
## aldex.effect: calculating effect sizes
results_lean <-
results %>%
rownames_to_column("Feature") %>%
select(Feature,
logFC_Between=diff.btw,
logFC_Within=diff.win,
Abundance_EA=rab.win.EA,
Abundance_W=rab.win.W,
Pvalue=we.ep,
FDR=we.eBH,
EffectSize=effect) %>%
mutate(logFC_EA_vs_W=-(logFC_Between)) %>%
separate(Feature,sep=";",into=c("K","P","C","O","F","Genus"),remove=F)
# significant results
sigres_lean <-
results_lean %>%
filter(FDR<0.1 & abs(logFC_Between)>1)
Nice.Table(sigres_lean)
# volcano plot
ggplot(results_lean, aes(x = logFC_EA_vs_W, y=-log10(FDR))) +
geom_point() +
gghighlight(FDR < 0.1 & abs(logFC_Between)>1, label_key = Genus) +
theme_bw() +
theme(plot.title = element_text(hjust = 0.5)) +
ggtitle("Lean individuals") +
xlab("Log2 fold difference (EA/W)") +
ylab("-Log10(FDR)") +
xlim(-6,6)
## Warning: Removed 1 rows containing missing values (geom_point).

#ggsave("/Volumes/turnbaughlab/qb3share/qiyanang/IDEO_manuscript_Rd2/figures/figures_16S_human_leanobese/aldex_lean_volplot.pdf", height=2.5, width=2.5, useDingbats=F)
# plot abundances of significant genera
genera %>%
Make.CLR() %>%
as.data.frame() %>%
rownames_to_column("Feature") %>%
filter(Feature %in% sigres_lean$Feature) %>%
pivot_longer(-Feature, names_to = "SampleID", values_to = "CLR") %>%
left_join(f.meta) %>%
separate(Feature, sep=";", into=c("K","P","C","O","Family","Genus")) %>%
ggplot(aes(x=Ethnicity, y=CLR, fill=Ethnicity)) +
geom_boxplot(outlier.shape=NA) +
geom_jitter(shape=21, size=1, height=0, width=0.1) +
facet_wrap(~Genus, scales="free", nrow=2) +
theme_boxplot() +
scale_fill_manual(values = c(EA=Chinesecolor, W=Whitecolor)) +
ylab("Abundance (CLR)")
## Joining, by = "SampleID"

#ggsave("/Volumes/turnbaughlab/qb3share/qiyanang/IDEO_manuscript_Rd2/figures/figures_16S_human_leanobese/aldex_lean_genera.pdf", height=4, width=6, useDingbats=F)
Differential Abundance on genera: Aldex2 (Obese subjects)
# filter obese subjects
f.meta<-metadata %>% rownames_to_column("SampleID") %>% filter(IDEO_BMI_Class=="Obese")
f.SVtab<-SVtab[,f.meta$SampleID]
# summarize table to genus level
genera<-Summarize.Taxa(f.SVtab, lookup)$Genus
f.genera<-Fraction.Filter(genera,0.0005)
## [1] "Filtering table at a min fraction of 5e-04 of feature table..."
## [1] "...There are 4628776 reads and 243 features"
## [1] "...After filtering there are 4560655 reads and 94 OTUs"
# aldex
results <- aldex(f.genera, f.meta$Ethnicity, mc.samples = 128, denom = "all", test = "t", effect = TRUE, include.sample.summary = TRUE)
## aldex.clr: generating Monte-Carlo instances and clr values
## operating in serial mode
## computing center with all features
## aldex.ttest: doing t-test
## aldex.effect: calculating effect sizes
results_obese <-
results %>%
rownames_to_column("Feature") %>%
select(Feature,
logFC_Between=diff.btw,
logFC_Within=diff.win,
Abundance_EA=rab.win.EA,
Abundance_W=rab.win.W,
Pvalue=we.ep,
FDR=we.eBH,
EffectSize=effect) %>%
mutate(logFC_EA_vs_W=-(logFC_Between)) %>%
separate(Feature,sep=";",into=c("K","P","C","O","F","Genus"),remove=F)
# significant results
sigres_obese <-
results_obese %>%
filter(FDR<0.1 & abs(logFC_Between)>1)
Nice.Table(sigres_obese)
# volcano plot
ggplot(results_obese, aes(x = logFC_EA_vs_W, y=-log10(FDR))) +
geom_point() +
gghighlight(FDR < 0.1 & abs(logFC_Between)>1, label_key = Genus) +
theme_bw() +
theme(plot.title = element_text(hjust = 0.5)) +
ggtitle("Obese individuals") +
xlab("Log2 fold difference (EA/W)") +
ylab("-Log10(FDR)") +
xlim(-9,9)

#ggsave("/Volumes/turnbaughlab/qb3share/qiyanang/IDEO_manuscript_Rd2/figures/figures_16S_human_leanobese/aldex_obese_volplot.pdf", height=2.5, width=2.5, useDingbats=F)
# plot abundances of significant genera
genera %>%
Make.CLR() %>%
as.data.frame() %>%
rownames_to_column("Feature") %>%
filter(Feature %in% sigres_obese$Feature) %>%
pivot_longer(-Feature, names_to = "SampleID", values_to = "CLR") %>%
left_join(f.meta) %>%
separate(Feature, sep=";", into=c("K","P","C","O","Family","Genus")) %>%
ggplot(aes(x=Ethnicity, y=CLR, fill=Ethnicity)) +
geom_boxplot(outlier.shape=NA) +
geom_jitter(shape=21, size=1, height=0, width=0.1) +
facet_wrap(~Genus, scales="free", nrow=1) +
theme_boxplot() +
scale_fill_manual(values = c(EA=Chinesecolor, W=Whitecolor)) +
ylab("Abundance (CLR)")
## Joining, by = "SampleID"

#ggsave("/Volumes/turnbaughlab/qb3share/qiyanang/IDEO_manuscript_Rd2/figures/figures_16S_human_leanobese/aldex_obese_genera.pdf", height=2, width=4, useDingbats=F)